﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Mail;

namespace ErrorMail
{
    public class ErrorMail
    {
        public int SendEmail(string SoftWare,string EndDate)
        {
            string text = "xtiandi@163.com";
            string subject = "<" + SoftWare + ">软件即将过期提示！";
            string body = "<" + SoftWare + ">软件即将过期提示！\r\n 本软件将于" + EndDate + "过期请更新软件";
            string[] array = text.Split('@');
            SmtpClient smtpClient = new SmtpClient("smtp.163.com");
            smtpClient.UseDefaultCredentials = false;
            smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtpClient.Credentials = new NetworkCredential(array[0].ToString(), "20081011");
            MailMessage mailMessage = new MailMessage();
            mailMessage.From = new MailAddress(text);
            mailMessage.To.Add(new MailAddress("613329777@qq.com"));
            mailMessage.Subject = subject;
            mailMessage.SubjectEncoding = Encoding.UTF8;
            mailMessage.Body = body;
            mailMessage.BodyEncoding = Encoding.UTF8;
            mailMessage.IsBodyHtml = true;
            mailMessage.Priority = MailPriority.High;
            try
            {
                smtpClient.Send(mailMessage);
                return 1;
            }
            catch
            {
                return 0;
            }
        }
    }


}
